useR 2019 - Toulouse - 2019/07/09

Produce publication ready thematic maps

Standing on the Shoulders of Giants

Previously:

sp & rgeos

Since version 2.0.0:

Main Features: Symbologies

Main Features: Transformations

Main Features: Map Layout

Cheat Sheet

Website

Vignette

Alternative Solutions

ggplot2 (Wickham, 2016) + ggspatial (Dunnington, 2018)

  • A general purpose graphic library
  • Better integration of sf objects.

tmap (Tennekes, 2018)

  • A mapping library with similar functionalities
  • Uses a different grammar (à la ggplot2)
  • Allows interactive maps
  • Uses more dependancies

library(sf)
library(cartography)
# path to the geo file embedded in cartography
path <- system.file("gpkg/mtq.gpkg", 
                    package = "cartography")
# import to an sf object
mtq <- st_read(dsn = path, quiet = TRUE)
# Set figure margins
par(mar = c(0,0,1.2,0), bg = "#b5d0d0")
# Plot the choropleth map
choroLayer(
  x = mtq, var = "MED", 
  method = "equal", nclass = 4, 
  col = carto.pal(pal1 = "sand.pal", n1 = 4),
  legend.values.rnd = -2, legend.pos = "left", 
  legend.title.txt = "Median Income\n(in euros)"
) 
# Plot a layout
layoutLayer(
  title="Wealth in Martinique, 2015", 
  author = "T. Giraud, 2019", 
  sources = "Sources: Insee and IGN - 2018", 
  scale = 5, north = TRUE,
  tabtitle = TRUE, frame = FALSE
)



  • osrm: Get road distances (time) between each municipalities.

  • SpatialPosition: Compute gravitationnal accessibility based on road distances.

  • cartography::getBreaks(): Classify data

  • cartography::carto.pal(): Use color palettes from the package

  • cartography::choroLayer(): Plot the choropleth map

  • cartography::getFigDim(): Find the correct ratio for png export.

  • sf: a lot geodata transformations

  • cartography::propSymbolsLayer(): Display the proportional symbols

  • cartography::layoutLayer(): Display the map layout

  • cartography::getPencilLayer(): Transform polygons to hand-drawn polylines

  • cartography::choroLayer(): Display a choropleth map




  • spatstats: Compute KDE

  • tanaka: Display the shaded contour lines

  • cartography::LegendChoro(): Plot the Legend

  • cartography::layoutLayer(): Plot the map layout

  • cartography::choroLayer(): Plot a choropleth map

  • cartography::getBorders(): Extract borders between countries

  • cartography::discLayer(): Map the discontinuities on borders

  • cartography::layoutLayer(): Map layout

Thank You